package com.atguigu.serviceedu.controller;


import com.atguigu.commonutils.R;
import com.atguigu.serviceedu.entity.EduVideo;
import com.atguigu.serviceedu.entity.chaptervo.VideoVo;
import com.atguigu.serviceedu.service.EduVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author xuan
 * @since 2020-04-13
 */
//@CrossOrigin
@RestController
@RequestMapping("edu/video")
public class EduVideoController {
    @Autowired
    EduVideoService videoService;

    @PostMapping("addVideo")
    public R addVideo(@RequestBody EduVideo video){
        boolean status = videoService.edit(video);
        return status?R.ok():R.error();
    }

    @PutMapping("updateVideo")
    public R updateVideo(@RequestBody EduVideo video){
        boolean status = videoService.edit(video);
        return status?R.ok():R.error();
    }

    @DeleteMapping("deleteVideo/{videoId}")
    public R deleteVideo(@PathVariable("videoId") String videoId){
        boolean status = videoService.delete(videoId);
        return status?R.ok():R.error();
    }

    @DeleteMapping("deleteVideoFile/{videoId}")
    public R deleteVideoFile(@PathVariable("videoId") String videoId){
        boolean status = videoService.deleteVideoFile(videoId);
        return status?R.ok():R.error();
    }

}

